<?php 
define("CCTRL", "region");
define("CCTRLNAME", "region");
session_start();
class region extends CI_Controller  {

        /**
        * Index Page for this controller.
        *
        * Maps to the following URL
        * 		http://example.com/index.php/welcome
        *	- or -  
        * 		http://example.com/index.php/welcome/index
        *	- or -
        * Since this controller is set as the default controller in 
        * config/routes.php, it's displayed at http://example.com/
        *
        * So any other public methods not prefixed with an underscore will
        * map to /index.php/welcome/<method_name>
        * @see http://codeigniter.com/user_guide/general/urls.html
        */
       //private $colModel = array("ID","Name","Level","Status","Insert","Update","Delete");
       function __construct()
        {
            parent::__construct();
            $this->load->helper('url');
            $this->load->library('smarty3');
            $this->load->model('APanel/region_model');
            include APPPATH . 'libraries/defu.php';
            $this->smarty=new CI_Smarty3();$this->smarty->error_reporting = E_ALL & ~E_NOTICE;
            $this->region_model=new region_model();
            
        }
        public function index()
	{
            //unset($_SESSION["ADP"][CCTRL."-JQX"]["colModel"]);
            if(!checkAuthority(CCTRLNAME)){
                $this->smarty
                        ->assign('_SESSION', $_SESSION)
                        ->display("sys/04_access_denied");
                return;
            }
            $Data=null;
            $this->smarty
                    ->assign('_SESSION', $_SESSION)
                    ->assign('Data', $Data)
                    ->display("APanel/".CCTRL."/".CCTRL);
	}
        function jqgrid_city(){
            $jDatas=array();
                $aResult=$this->region_model->binding_city();
                $oRows=$aResult['rows'];
                // get data and store in a json array
                foreach ($oRows as $oRow) {
                    $aCel=array(
                        "ID"=>$oRow->ID,
                        "TenTinhThanh"=>$oRow->TenTinhThanh,
                        "Status"=>$oRow->Status
                    );
                    $jDatas[] = $aCel;
                }
            $aData[] = array(
                'TotalRows' => $aResult['total_rows'],
                'Rows' => $jDatas
            );
            echo json_encode($aData);
        }
        function jqgrid_district($city=""){
            $jDatas=array();
                $aResult=$this->region_model->binding_district($city);
                $oRows=$aResult['rows'];
                // get data and store in a json array
                foreach ($oRows as $oRow) {
                    $aCel=array(
                        "ID"=>$oRow->ID,
                        "TenQuanHuyen"=>$oRow->TenQuanHuyen,
                        "Status"=>$oRow->Status
                    );
                    $jDatas[] = $aCel;
                }
            $aData[] = array(
                'TotalRows' => $aResult['total_rows'],
                'Rows' => $jDatas
            );
            echo json_encode($aData);
        }
        function jqgrid_ward($district=""){
            $jDatas=array();
                $aResult=$this->region_model->binding_ward($district);
                $oRows=$aResult['rows'];
                // get data and store in a json array
                foreach ($oRows as $oRow) {
                    $aCel=array(
                        "ID"=>$oRow->ID,
                        "TenPhuongXa"=>$oRow->TenPhuongXa,
                        "Status"=>$oRow->Status
                    );
                    $jDatas[] = $aCel;
                }
            $aData[] = array(
                'TotalRows' => $aResult['total_rows'],
                'Rows' => $jDatas
            );
            echo json_encode($aData);
        }
}

/* End of file welcome.php */
/* Location: ./application/controllers/welcome.php */